<?php 

class MdateText extends sElement {
	public function __construct($name, $label, $value, $more) {
		$this->setName($name);
		$this->setlabel($label);
		$this->setValue($value);
	}

	public function getHTML() {
		$m = array();
		$id = 'date_' . substr(md5(uniqid(rand())),0,5);
		$id = $this->getName();
		$m[] = 'id="'.$id.'"';

		$m[] = 'value="'.htmlspecialchars($this->getValue(), null, Mform::$encoding).'"';
		$r = '<div id="'.$this->getName().'Container" style="display:none; position:absolute; left:10px; top:10px;"></div>';
		$r .= '<input type="text" name="'.$this->getName().'" '.implode(' ', $m).' 
		onclick="var M = new cal(\''.$this->getName().'\', \''.$this->getName().'Container\');M.make();" />';
		$r .= $this->writeHeader();
		return $r;
	}

	public function writeHeader($path=null) {
		if(!$path) {
			$path = 'www/js/yui/';
		}
		return '
		<script type="text/javascript" src="'.$path.'build/yahoo/yahoo.js"></script>
		<script type="text/javascript" src="'.$path.'build/event/event.js" ></script>
		<script type="text/javascript" src="'.$path.'build/dom/dom.js" ></script>
		<script type="text/javascript" src="'.$path.'build/calendar/calendar.js"></script>
		<link type="text/css" rel="stylesheet" href="'.$path.'build/calendar/assets/calendar.css">';
	}
	
	
}

?>